package jay.home.bet.web.struts;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jay.home.bet.domain.Item;
import jay.home.bet.domain.Order;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class ListCompOrdersAction extends BaseAction
{
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws Exception
	{
		Object ocompid = request.getParameter("compid");
			if(ocompid == null)return mapping.findForward("error");
		String compid = (String)ocompid;
		List<Order> orders = getOrderService().getOrdersByComp(compid, 1, 100);
		for(Order order : orders)
			for(Item item : order.getItems())
				item.setEvent(getOddsService().getEvent(item.getEventid()));
		request.setAttribute("orders", orders);
		return mapping.findForward("SUCCESS");
	}
}
